home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-05 | 7.2 KB | 280 lines | [TEXT/CWIE] |
- // ===========================================================================
- // AGADemoApp.cp ©1994-1995 Metrowerks Inc. All rights reserved.
- // ===========================================================================
- //
- // This file contains the starter code for a PowerPlant application
-
- #include "AGADemoApp.h"
-
- #include <LGrowZone.h>
- #include <LWindow.h>
- #include <PP_Messages.h>
- #include <PP_Resources.h>
- #include <PPobClasses.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <URegistrar.h>
- #include <LEditField.h>
-
- #include "LAGADefaultOutline.h"
- #include "LAGAIconButton.h"
- #include "LAGAPushButton.h"
- #include "LAGACheckBox.h"
- #include "LAGAIndexTab.h"
- #include "LAGARadioButton.h"
- #include "LAGAEditField.h"
- #include "LAGAEmbossedView.h"
- #include "LAGAGroupBox.h"
- #include "LAGASeparator.h"
- #include "LAGADialogBox.h"
- #include "LAGAWindow.h"
- #include "CAboutBoxDB.h"
-
- #include "LPPobView.h"
- #include "LAGAPopupMenu.h"
- #include "LAGAPointedVSlider.h"
- #include "LAGAPointedHSlider.h"
- #include "LAGASquareVSlider.h"
- #include "LAGASquareHSlider.h"
-
- #include "LAGAProgressIndicator.h"
- #include "LAGAIndetermProgress.h"
-
- #include "LAGADiscloTriangle.h"
- #include "LAGALittleArrows.h"
-
- // put declarations for resource ids (ResIDTs) here
-
- const ResIDT window_Sample = 1; // EXAMPLE
-
-
- // ===========================================================================
- // • Main Program
- // ===========================================================================
-
- void main(void)
- {
- // Set Debugging options
- SetDebugThrow_(debugAction_Alert);
- SetDebugSignal_(debugAction_Alert);
-
- InitializeHeap(3); // Initialize Memory Manager
- // Parameter is number of Master Pointer
- // blocks to allocate
-
- // Initialize standard Toolbox managers
- UQDGlobals::InitializeToolbox(&qd);
-
- new LGrowZone(20000); // Install a GrowZone function to catch
- // low memory situations.
-
- AGADemoApp theApp; // replace this with your App type
- theApp.Run();
- }
-
-
- // ---------------------------------------------------------------------------
- // • CPPStarterApp // replace this with your App type
- // ---------------------------------------------------------------------------
- // Constructor
-
- AGADemoApp::AGADemoApp()
-
- {
- // Register functions to create core PowerPlant classes
-
- RegisterAllPPClasses();
-
- // Register AGA classes
- RegisterAGAIndexTab();
- LAGAIconButton::RegisterClass();
- LAGAEmbossedView::RegisterClass();
- LAGACheckBox::RegisterClass();
- LAGARadioButton::RegisterClass();
- LAGAWindow::RegisterClass();
- LAGAEditField::RegisterClass();
- LAGAGroupBox::RegisterClass();
- LAGAPushButton::RegisterClass();
- LAGASecondaryGroupBox::RegisterClass();
- LAGASeparator::RegisterClass();
- LAGADialogBox::RegisterClass();
- LAGAWindow::RegisterClass();
- URegistrar::RegisterClass(CAboutBoxDB::class_ID, (ClassCreatorFunc)CAboutBoxDB::CreateAboutBoxDBStream);
-
- URegistrar::RegisterClass(LPPobView::class_ID, (ClassCreatorFunc)LPPobView::CreatePPobViewStream);
- LAGAPopupMenu::RegisterClass();
- LAGAPointedVSlider::RegisterClass();
- LAGAPointedHSlider::RegisterClass();
- LAGASquareVSlider::RegisterClass();
- LAGASquareHSlider::RegisterClass();
-
- LAGAProgressIndicator::RegisterClass();
- LAGAIndetermProgress::RegisterClass();
-
- LAGADiscloTriangle::RegisterClass();
- LAGALittleArrows::RegisterClass();
-
- // Quick&Dirty object to animate the determinate progress indicator
- URegistrar::RegisterClass(CProgressAnimator::class_ID, (ClassCreatorFunc)CProgressAnimator::CreateProgressAnimatorStream);
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~CPPStarterApp // replace this with your App type
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- AGADemoApp::~AGADemoApp()
-
- {
- }
-
- // ---------------------------------------------------------------------------
- // • StartUp
- // ---------------------------------------------------------------------------
- // This function lets you do something when the application starts up.
- // For example, you could issue your own new command, or respond to a system
- // oDoc (open document) event.
-
- void AGADemoApp::StartUp()
-
- {
- ObeyCommand(cmd_New, nil); // EXAMPLE, create a new window
- }
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean AGADemoApp::ObeyCommand (CommandT inCommand, void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand)
- {
-
- // Deal with command messages (defined in PP_Messages.h).
- // Any that you don't handle will be passed to LApplication
-
- case cmd_New:
- // EXAMPLE, create a new window
- LWindow *theWindow;
- theWindow = LWindow::CreateWindow(window_Sample, this);
- UReanimator::LinkListenerToControls(this, theWindow, window_Sample);
- theWindow->Show();
- break;
-
- default:
- cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // This function enables menu commands.
- //
-
- void AGADemoApp::FindCommandStatus ( CommandT inCommand, Boolean &outEnabled,
- Boolean &outUsesMark, Char16 &outMark,
- Str255 outName)
- {
-
- switch (inCommand)
- {
-
- // Return menu item status according to command messages.
- // Any that you don't handle will be passed to LApplication
-
- case cmd_New: // EXAMPLE
- outEnabled = true; // enable the New command
- break;
-
- default:
- LApplication::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
- void AGADemoApp::ShowAboutBox()
-
- {
- LAGADialogBox *theDialog;
- theDialog = (LAGADialogBox *)LWindow::CreateWindow(999, this );
- Assert_(theDialog != nil);
- theDialog->Show();
- }
-
- void AGADemoApp::ListenToMessage (MessageT inMessage, void *ioParam)
-
- {
- if (inMessage == -10009)
- ShowAboutBox();
- }
-
- //----------------------------------------------------------------------------------------------------------------
-
- CProgressAnimator* CProgressAnimator::CreateProgressAnimatorStream (LStream* inStream)
-
- {
- return(new CProgressAnimator(inStream));
- }
-
- CProgressAnimator::CProgressAnimator (LStream *inStream) : LView(inStream)
-
- {
- }
-
- void CProgressAnimator::FinishCreateSelf ()
-
- {
- StartIdling();
- }
-
- void CProgressAnimator::SpendTime (const EventRecord &inMacEvent)
-
- {
- static long time = 0;
- static Boolean up = true;
-
- if (::TickCount() > time)
- {
- LView *start = GetSuperView();
- LView *theWindow;
- while (start)
- {
- theWindow = start;
- start = start->GetSuperView();
- }
- LAGAProgressIndicator *thePI = (LAGAProgressIndicator *)theWindow->FindPaneByID(2003);
- if (thePI != nil)
- {
- Int32 max = thePI->GetMaxValue();
- Int32 val = thePI->GetValue();
- Int32 min = thePI->GetMinValue();
- if (up)
- {
- if (val >= max)
- up = false;
- else
- thePI->IncrementValue();
- }
- else
- {
- if (val <= min)
- up = true;
- else
- thePI->SetValue(val - 1);
- }
- }
- time = TickCount() + 10;
- }
- }
-
-